home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
fish
/
676-700
/
681
/
term
/
source.lha
/
MiscPanel.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-09
|
8KB
|
273 lines
/*
** $Id: MiscPanel.c,v 1.4 92/04/21 16:59:05 olsen Sta Locker: olsen $
** $Revision: 1.4 $
** $Date: 92/04/21 16:59:05 $
**
** Editing panel for miscellaneous parts of the configuration
**
** Copyright © 1990-1992 by Olaf `Olsen' Barthel & MXM
** All Rights Reserved
*/
#include "termGlobal.h"
enum { GAD_PRIORITY,GAD_OVERRIDE,GAD_BACKUP,GAD_AUTOUPLOAD,GAD_SETBIT,GAD_MAXBUFFSIZE,
GAD_BUFFERENABLED,GAD_SHOWFASTMACROS,GAD_USE,GAD_CANCEL };
#define WIDTH 344
#define HEIGHT 129
STATIC struct Gadget *
CreateAllGadgets(struct Configuration *Config,struct Gadget **GadgetArray,struct Gadget **GadgetList,APTR VisualInfo,UWORD TopEdge)
{
struct Gadget *Gadget;
struct NewGadget NewGadget;
UWORD Counter = 0;
memset(&NewGadget,0,sizeof(struct NewGadget));
if(Gadget = CreateContext(GadgetList))
{
NewGadget . ng_LeftEdge = 193;
NewGadget . ng_TopEdge = 1 + TopEdge;
NewGadget . ng_Width = 140;
NewGadget . ng_Height = 10;
NewGadget . ng_GadgetText = LocaleString(MSG_MISCPANEL_PROGRAM_PRIORITY_GAD);
NewGadget . ng_TextAttr = &DefaultFont;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_Flags = PLACETEXT_LEFT;
NewGadget . ng_VisualInfo = VisualInfo;
GadgetArray[Counter++] = Gadget = CreateGadget(SLIDER_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTSL_Min, -128,
GTSL_Max, 127,
GTSL_Level, Config -> Priority,
GTSL_MaxLevelLen, 4,
GTSL_LevelFormat, "%4ld",
PGA_Freedom, LORIENT_HORIZ,
GA_Immediate, TRUE,
GA_RelVerify, TRUE,
TAG_DONE);
NewGadget . ng_TopEdge = NewGadget . ng_TopEdge + NewGadget . ng_Height + 1;
NewGadget . ng_Width = 26;
NewGadget . ng_GadgetText = LocaleString(MSG_MISCPANEL_OVERRIDE_TRANSFER_PATH_GAD);
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_Height = 11;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GTCB_Checked, Config -> OverridePath,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_TopEdge = NewGadget . ng_TopEdge + NewGadget . ng_Height + 1;
NewGadget . ng_GadgetText = LocaleString(MSG_MISCPANEL_BACKUP_CONFIGURATION_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GTCB_Checked, Config -> BackupConfig,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_TopEdge = NewGadget . ng_TopEdge + NewGadget . ng_Height + 1;
NewGadget . ng_GadgetText = LocaleString(MSG_MISCPANEL_USE_AUTO_UPLOAD_PANEL_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GTCB_Checked, Config -> AutoUpload,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_TopEdge = NewGadget . ng_TopEdge + NewGadget . ng_Height + 1;
NewGadget . ng_GadgetText = LocaleString(MSG_MISCPANEL_SET_ARCHIVED_BIT_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GTCB_Checked, Config -> SetArchivedBit,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_TopEdge = NewGadget . ng_TopEdge + NewGadget . ng_Height + 1;
NewGadget . ng_GadgetText = LocaleString(MSG_MISCPANEL_MAXIMUM_BUFFER_SIZE_GAD);
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_Height = 14;
NewGadget . ng_Width = 140;
GadgetArray[Counter++] = Gadget = CreateGadget(INTEGER_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTIN_MaxChars, 8,
GTIN_Number, Config -> MaxLogBuffSize,
GTST_EditHook, &CommandHook,
GA_Immediate, TRUE,
TAG_DONE);
NewGadget . ng_TopEdge = NewGadget . ng_TopEdge + NewGadget . ng_Height + 1;
NewGadget . ng_Width = 26;
NewGadget . ng_Height = 11;
NewGadget . ng_GadgetText = LocaleString(MSG_MISCPANEL_BUFFER_ENABLED_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GTCB_Checked, Config -> BufferEnabled,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_TopEdge = NewGadget . ng_TopEdge + NewGadget . ng_Height + 1;
NewGadget . ng_GadgetText = LocaleString(MSG_MISCPANEL_SHOW_FAST_MACROS_GAD);
NewGadget . ng_GadgetID = Counter;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GTCB_Checked, Config -> OpenFastMacroPanel,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_Width = 88; /* NEW 52 */
NewGadget . ng_Height = 12;
NewGadget . ng_GadgetText = LocaleString(MSG_GLOBAL_USE_GAD);
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_Flags = 0;
NewGadget . ng_LeftEdge = 10;
NewGadget . ng_TopEdge = HEIGHT - 3 - NewGadget . ng_Height;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_GLOBAL_CANCEL_GAD);
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = WIDTH - 10 - NewGadget . ng_Width;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
}
return(Gadget);
}
VOID
MiscPanel(struct Configuration *Config)
{
struct Window *PanelWindow;
struct Gadget *GadgetList = NULL;
struct Gadget *GadgetArray[GAD_CANCEL + 1];
CopyMem(Config,&PrivateConfig,sizeof(struct Configuration));
if(CreateAllGadgets(Config,&GadgetArray[0],&GadgetList,VisualInfo,Screen -> WBorTop + Screen -> Font -> ta_YSize + 1))
{
if(PanelWindow = OpenWindowTags(NULL,
WA_Left, (Screen -> Width - WIDTH) >> 1,
WA_Top, (Screen -> Height - HEIGHT) >> 1,
WA_Width, WIDTH,
WA_Height, HEIGHT,
WA_Activate, TRUE,
WA_DragBar, TRUE,
WA_DepthGadget, TRUE,
WA_RMBTrap, TRUE,
WA_DepthGadget, TRUE,
WA_CloseGadget, TRUE,
WA_CustomScreen,Screen,
WA_IDCMP, IDCMP_GADGETDOWN | IDCMP_ACTIVEWINDOW | IDCMP_VANILLAKEY | IDCMP_CLOSEWINDOW | BUTTONIDCMP | CHECKBOXIDCMP | SLIDERIDCMP | INTEGERIDCMP,
WA_Title, LocaleString(MSG_MISCPANEL_MISCELLANEOUS_PREFERENCES_TXT),
TAG_DONE))
{
struct IntuiMessage *Massage;
ULONG Class,Code;
struct Gadget *Gadget;
BYTE Terminated = FALSE;
PushWindow(PanelWindow);
AddGList(PanelWindow,GadgetList,(UWORD)-1,(UWORD)-1,NULL);
RefreshGList(GadgetList,PanelWindow,NULL,(UWORD)-1);
GT_RefreshWindow(PanelWindow,NULL);
ActiveGadget = NULL;
while(!Terminated)
{
WaitPort(PanelWindow -> UserPort);
while(!Terminated && (Massage = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort)))
{
Class = Massage -> Class;
Code = Massage -> Code;
Gadget = (struct Gadget *)Massage -> IAddress;
GT_ReplyIMsg(Massage);
if(Class == IDCMP_VANILLAKEY)
KeySelect(GadgetArray,GAD_CANCEL,Code,PanelWindow,&Gadget,&Class,&Code);
if(Class == IDCMP_GADGETDOWN)
{
if((Gadget -> GadgetType & GTYP_GTYPEMASK) == GTYP_STRGADGET)
ActiveGadget = Gadget;
}
if(Class == IDCMP_ACTIVEWINDOW && ActiveGadget)
ActivateGadget(ActiveGadget,PanelWindow,NULL);
if(Class == IDCMP_CLOSEWINDOW)
{
Terminated = TRUE;
Config -> Priority = PrivateConfig . Priority;
}
if(Class == IDCMP_MOUSEMOVE)
{
if(Gadget -> GadgetID == GAD_PRIORITY)
Config -> Priority = (BYTE)Code;
}
if(Class == IDCMP_GADGETUP)
{
switch(Gadget -> GadgetID)
{
case GAD_PRIORITY: Config -> Priority = (BYTE)Code;
break;
case GAD_USE: Terminated = TRUE;
Config -> OverridePath = GT_CHECKED(GadgetArray[GAD_OVERRIDE]);
Config -> BackupConfig = GT_CHECKED(GadgetArray[GAD_BACKUP]);
Config -> AutoUpload = GT_CHECKED(GadgetArray[GAD_AUTOUPLOAD]);
Config -> SetArchivedBit = GT_CHECKED(GadgetArray[GAD_SETBIT]);
Config -> BufferEnabled = GT_CHECKED(GadgetArray[GAD_BUFFERENABLED]);
Config -> OpenFastMacroPanel = GT_CHECKED(GadgetArray[GAD_SHOWFASTMACROS]);
Config -> MaxLogBuffSize = GT_INTEGER(GadgetArray[GAD_MAXBUFFSIZE]);
if(Config -> MaxLogBuffSize && Config -> MaxLogBuffSize < 2000)
Config -> MaxLogBuffSize = 2000;
break;
case GAD_CANCEL: Terminated = TRUE;
Config -> Priority = PrivateConfig . Priority;
break;
default: break;
}
}
}
}
RemoveGList(PanelWindow,GadgetList,(UWORD)-1);
PopWindow();
CloseWindow(PanelWindow);
}
}
FreeGadgets(GadgetList);
}